using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;

namespace QLNhanKhau
{
    public partial class frmMenu : DevComponents.DotNetBar.Metro.MetroForm
    {
        public frmMenu()
        {
            InitializeComponent();
        }

        private void addNewTab(string strTabName, UserControl ucContent)
        {
            //-----------If exist tabpage then exit---------------
            foreach (TabItem tabPage in tabMain.Tabs)
                if (tabPage.Text == strTabName)
                {
                    tabMain.SelectedTab = tabPage;
                    return;
                }
            //-------------------------Clear Tab Before---------------
            if (tabMain.Tabs.Count > 1)
              tabMain.Tabs.RemoveAt(1);

            TabControlPanel newTabPanel = new DevComponents.DotNetBar.TabControlPanel();
            TabItem newTabPage = new TabItem(this.components);
            newTabPage.ImageIndex = 0;
            //newTabPage.MouseDown += new System.Windows.Forms.MouseEventHandler(tabItem_MouseDown);
            newTabPanel.Dock = System.Windows.Forms.DockStyle.Fill;
            newTabPanel.Location = new System.Drawing.Point(0, 26);
            newTabPanel.Name = "panel" + strTabName;
            newTabPanel.Padding = new System.Windows.Forms.Padding(1);
            newTabPanel.Size = new System.Drawing.Size(1230, 384);
            newTabPanel.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(142)))), ((int)(((byte)(179)))), ((int)(((byte)(231)))));
            newTabPanel.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(237)))), ((int)(((byte)(254)))));
            newTabPanel.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
            newTabPanel.Style.BorderColor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(97)))), ((int)(((byte)(156)))));
            newTabPanel.Style.BorderSide = ((DevComponents.DotNetBar.eBorderSide)(((DevComponents.DotNetBar.eBorderSide.Left | DevComponents.DotNetBar.eBorderSide.Right)
                        | DevComponents.DotNetBar.eBorderSide.Bottom)));
            newTabPanel.Style.GradientAngle = 90;
            newTabPanel.TabIndex = 2;
            newTabPanel.TabItem = newTabPage;
            //-------------New  tab page---------------------
            Random ran = new Random();
            newTabPage.Name = strTabName + ran.Next(100000) + ran.Next(22342);
            newTabPage.AttachedControl = newTabPanel;
            newTabPage.Text = strTabName;
            ucContent.Dock = DockStyle.Fill;
            newTabPanel.Controls.Add(ucContent);
            //------------add Tab page to Tab control-------------
            tabMain.Controls.Add(newTabPanel);
            tabMain.Tabs.Add(newTabPage);
            tabMain.SelectedTab = newTabPage;
        }

        private void btnDanToc_Click(object sender, EventArgs e)
        {
            UCDanToc ucdt = new UCDanToc();
            addNewTab("Dân tộc", ucdt);
        }

        private void tabMain_TabItemClose(object sender, TabStripActionEventArgs e)
        {
            tabMain.Tabs.Remove(tabMain.SelectedTab);
        }

        private void btnTonGiao_Click(object sender, EventArgs e)
        {
            UCTonGiao uctg = new UCTonGiao();
            addNewTab("Tôn giáo", uctg);
        }

        private void btnQuocTich_Click(object sender, EventArgs e)
        {
            UCQuocTich ucqt = new UCQuocTich();
            addNewTab("Quốc tịch", ucqt);
        }

        private void btnTimKiem_Click(object sender, EventArgs e)
        {
            UCTimKiem uctk = new UCTimKiem();
            addNewTab("Tìm kiếm", uctk);
        }

        private void btnQuanTri_Click(object sender, EventArgs e)
        {
            UCQuanTri ucqt = new UCQuanTri();
            addNewTab("Quản trị", ucqt);

        }
        private void frmMenu_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void btnPhuongXa_Click(object sender, EventArgs e)
        {
            UCPhuongXa ucpx = new UCPhuongXa();
            addNewTab("Phường xã", ucpx);
        }

        private void frmMenu_Load(object sender, EventArgs e)
        {
            //labGioiThieu.Text = labGioiThieu.Text + ThietLapBLL.LoadDiaPhuong();
        }


        //private void btnDoTuoi_Click(object sender, EventArgs e)
        //{
        //    frmDoTuoi dt = new frmDoTuoi();
        //    dt.ShowDialog();
        //    //UCThongKeNK uctk = new UCThongKeNK();
        //    //addNewTab("Nhân khẩu theo tuổi", uctk);
        //}

        //private void btnThongKeTonGiao_Click(object sender, EventArgs e)
        //{
        //    frmThongKeDanToc tkdt = new frmThongKeDanToc();
        //    tkdt.ShowDialog();
        //}

        private void btnNVQS_Click(object sender, EventArgs e)
        {
            Report rep = new Report("NVQS",true);
            rep.Print();
        }

        private void btnTrinhDoReport_Click(object sender, EventArgs e)
        {
            Report rep = new Report("TrinhDo",true);
            rep.Print();
        }

        private void btnNhanKhau_Click(object sender, EventArgs e)
        {
            Report rep = new Report("BaoCaoDanSo", true);
            rep.Print();
        }

       
    
    }
}